package com.tr.rentcar.model.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.tr.rentcar.model.GlobalParamHandler;
import com.tr.rentcar.model.bean.Friendlink;
import com.tr.rentcar.model.bean.PPT;
import com.tr.rentcar.model.jdbc.MySqlDb;
import com.tr.rentcar.model.jdbc.ResultHandler;

public class PPTdao implements ResultHandler<PPT>{
	MySqlDb db=MySqlDb.getInstance();
	
	public List<PPT> getAll() throws SQLException{
		String sql="select * from foreground_ppt";
		return db.executeQuery(sql, this);
	}
	/*
	 通过id修改该对象的图片地址
	 */
	public boolean updatetu(String fileName,Integer id) throws SQLException{
		String sql="update foreground_ppt set fp_photo=? where fp_id=?";
		return db.executeUpdate(sql, new GlobalParamHandler(fileName,id))>0;
	}
	
	/*
	 通过id找到该对象
	 */
	public PPT findbyid(Integer id) throws SQLException{
		String sql="select * from foreground_ppt where fp_id=?";
		return db.queryUninResult(sql, new GlobalParamHandler(id),this);
	}
	@Override
	public PPT doHander(Map<String, Object> row) {
		PPT ppt=new PPT();
		ppt.setFpId(Integer.parseInt(row.get("fp_id")+""));
		ppt.setFpPhoto(row.get("fp_photo")+"");
		ppt.setFpUrl(row.get("fp_url")+"");;
		return ppt;
		
	}

}
